< previous page page_493 next page >

Page 493
e10a6a0a59f035e870d90cca05b85fce.gif
X = Xmin
For i = 1 To NumX
    Z = Zmin
    For j = 1 To NumZ
        Y = 2 * Cos(2 * PI / 10 * z) * (5 - Abs(z)) / 5 + _
            0.25 * Sin(2 * x + x1) +_ 
            0.25 * Sin(1# * x + x1) + 0.5 * Rnd 
        TheGrid.SetValue X, Y, Z
        Z = Z + Dz
    Next j
    X = X + Dx
Next i
Figures 14.18 and 14.19 show the resulting pictures after the grids have been subdivided three times. Because each subdivision increases the number of areas in the grid by a factor of four, these pictures contain 43 = 64 times as many regions as the original grids. The underlying shape of the surfaces is determined by the original data shown in Figures 14.16 and 14.17. The subdivision of the grids adds further randomness to the surfaces and makes them look like surprisingly realistic mountain ranges.
Fractal Surfaces in Visual Basic
The FractalGrid3d class manages this kind of fractal surface. In most respects it behaves like the ZOrderGrid3d class. The major difference is that the FractalGrid3d class also includes routines to subdivide the grid randomly.
The GenerateSurface subroutine shown in the following code starts by resizing the Points array to make room for all the new data points it is about to generate. Next, it
z0513-01.gif
Figure 14.16
A simple, pseudo-random surface.

 
< previous page page_493 next page >